﻿using DocumentFormat.OpenXml.Wordprocessing;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NPOI.HSSF.UserModel.HSSFChart;

namespace Growatt.CreateCCode
{
    public class InsertFile
    {

        public static void InsertFileFunc(string  path,string pathCSV)
        {
            // 创建一个新的Excel文档
            HSSFWorkbook workbook = new HSSFWorkbook();
            // 创建一个工作表
            HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Sheet1");

            // 创建一个单元格
            HSSFRow row = (HSSFRow)sheet.CreateRow(0);
            HSSFCell cell = (HSSFCell)row.CreateCell(0);

            // 创建一个超链接到 .csv 文件
            HSSFHyperlink hyperlink = new HSSFHyperlink(HyperlinkType.File);
            hyperlink.Address = "path/to/your/file.csv"; // 替换为你的 .csv 文件路径
            cell.Hyperlink = hyperlink;
            cell.SetCellValue(pathCSV);

            // 保存Excel文档
            using (FileStream file = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                workbook.Write(file);
            }
        }
    }
}
